home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2451 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.4 KB

  1. Path: peer-news.britain.eu.net!psinntp!psinntp!psinntp!pipeline!not-for-mail
  2. From: gordo@nyc.pipeline.com (Gordon Krefting)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: When to use "->" vs "." when calling Member functions
  5. Date: 17 Jan 1996 10:15:23 -0500
  6. Organization: The Pipeline
  7. Message-ID: <4dj3qb$4kn@pipe3.nyc.pipeline.com>
  8. References: <4dhea1$6v8@ornews.intel.com>
  9. NNTP-Posting-Host: pipe3.nyc.pipeline.com
  10. X-PipeUser: gordo
  11. X-PipeHub: nyc.pipeline.com
  12. X-PipeGCOS: (Gordon Krefting)
  13. X-Newsreader: The Pipeline v3.4.0
  14.  
  15. On Jan 17, 1996 00:00:59 in article <When to use "->" vs "." when calling
  16. Member functions>, 'thurman_b_miller@ccm2.hf.intel.com (Thurman Miller)'
  17. wrote: 
  18.  
  19.  
  20. >I'm confused, so please no harsh remarks :) 
  21. >If I've got: 
  22. >class Cfoo 
  23. >{ 
  24. >    something * getptr(); 
  25. >    somethingelse* m_other; 
  26. >} 
  27. >something * foo::getptr() 
  28. >{ 
  29. >    return m_other; 
  30. >} 
  31. >Now...if I'm in another class.... 
  32. >    Cfoo foo; 
  33. >    somethingelse* = foo.getptr(); 
  34. >why doesn't the following work? 
  35. >    somethingelse* = foo->getptr(); 
  36. >I get compile error about no "->" overloaded operator.... 
  37. >Can someone point out the obvious when I use one notation over 
  38. >another? 
  39. >TIA 
  40. >Thurman 
  41.  
  42. Use "->" to access elements of an object when you have a pointer to the
  43. object. Use "." when you have the object itself: 
  44.  
  45. ... 
  46.    CFoo foo; 
  47.    CFoo * pfoo; 
  48.  
  49. ... 
  50.    foo.member = 1; 
  51.    pfoo->member = 1; 
  52.  
  53. HTH 
  54. gordo
  55.